package com.spring.datasource.multi;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;

@Aspect
public class MultiDatasourceAspect {

    @Pointcut("@annotation(com.spring.datasource.multi.Db)")
    public void point(){}

    @Before(value="point() && @annotation(db)",argNames ="db")
    public void before(JoinPoint joinPoint, Db db){
        String dbName = db.value();
        DatasourceKeyHolder.setKey(dbName);
    }

}
